package c2.cross.server.controller;

import c2.cross.business.CrossBody;
import easy.java.spring.annotation.MyGetMapping;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Slf4j
@RequestMapping("/demo/")
@Controller
public class DemoController extends CrossBaseController {

    @Resource
    private CrossBody body;

    // http://localhost:8585/demo/doDb
    @MyGetMapping("doDb")
    @ResponseBody
    public Object doDb() {
        log.info("演示模块的数据库操作能力");
        return body.demo.doDb();
    }

    // http://localhost:8585/demo/doRpc
    @MyGetMapping("doRpc")
    @ResponseBody
    public Object doRpc() throws Exception {
        log.info("演示模块的远程执行能力");
        return body.demo.doRpc();
    }

    // http://localhost:8585/demo/doTable
    @MyGetMapping("doTable")
    @ResponseBody
    public Object doTable() throws Exception {
        log.info("演示模块的Excel表格操作能力");
        return body.demo.doTable();
    }

    // http://localhost:8585/demo/doPlay
    @MyGetMapping("doPlay")
    @ResponseBody
    public Object doPlay() throws Exception {
        log.info("演示模块的构建战斗实例能力");
        return body.demo.doPlay();
    }

    // http://localhost:8585/demo/doMailSendToGame?demo=1
    @MyGetMapping("doMailSendToGame")
    @ResponseBody
    public Object doMailSendToGame(@RequestParam(defaultValue = "1") int demo) throws Exception {
        log.info("演示模块的发送邮件给游戏服");
        return body.demo.doMailSendToGame(demo);
    }

}
